<?php
error_reporting(0);
function page($num, $perpage, $curpage, $mpurl) {
    global $setting;
    $multipage = '';
    if ($num > $perpage) {
        $page = 10;
        $offset = 2;
        $pages = @ceil($num / $perpage);
        if ($page > $pages) {
            $from = 1;
            $to = $pages;
        } else {
            $from = $curpage - $offset;
            $to = $from + $page - 1;
            if ($from < 1) {
                $to = $curpage + 1 - $from;
                $from = 1;
                if ($to - $from < $page) {
                    $to = $page;
                }
            } elseif ($to > $pages) {
                $from = $pages - $page + 1;
                $to = $pages;
            }
        }
        $multipage = ($curpage - $offset > 1 && $pages > $page ? '<a href="' . $mpurl . '1" >首页</a>' . "\n" : '') .
                ($curpage > 1 ? '<a href="' . $mpurl . ($curpage - 1) . '"  >上一页</a>' . "\n" : '');
        for ($i = $from; $i <= $to; $i++) {
            $multipage .= $i == $curpage ? $i . "\n" :
                    '<a href="' . $mpurl . $i . '">[' . $i . ']</a>' . "\n";
        }
        $multipage .= ($curpage < $pages ? '<a href="' . $mpurl . ($curpage + 1) . '">下一页</a>' . "\n" : '') .
                ($to < $pages ? '<a   class="mar-r8" href="' . $mpurl . $pages . '" >最后一页</a>' . "\n" : '');
    }
    return $multipage;
}

require 'site/config.php';
require 'site/lib/db.class.php';
$db = new db(DB_HOST, DB_USER, DB_PW, DB_NAME, DB_CHARSET, DB_CONNECT);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn">

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" href="images/style.css" type="text/css" />
        <title>Tipask案例 -  Tipask问答系统 </title>
        <meta name="Keywords" content="tipask,tipask下载,php问答系统,仿百度知道源码，仿百度知道程序,仿百度知道系统,PHP仿百度知道源码,爱问程序,在线问答系统,在线问答程序" >
        <meta name="Description" content="Tipask旨在为大家提供开源、稳定、功能强大的、值得使用的问答系统！">
    </head>

    <body>

        <!-- wrap starts here -->
        <div id="wrap">

            <!--header -->
            <div id="navs">			
                <div id="header-links">
                    <p>
                        <a href="http://help.tipask.com/">演示站点</a> | 
                        <a href="http://bbs.tipask.com/">交流论坛</a>  |
                        <a href="http://www.tipask.com/tipask2.0.chm">Tipask手册下载</a>		
                    </p>		
                </div>			

                <!--header ends-->					
            </div>

            <div id="header">		

                <h1 id="logo"><a href="/">TIPASK</a></h1>		

                <form id="quick-search" action="http://help.tipask.com/question/search/2" method="post" >
                    <p>
                        <label for="qsearch">Search:</label>
                        <input class="tbox" id="qsearch" type="text" name="qsearch"  />
                        <input class="btn" alt="Search" type="image" name="searchsubmit" src="images/search.gif" />
                    </p>
                </form>			

            </div>


            <!-- navigation starts-->
            <div class="navigation">
                <a href="http://www.tipask.com/">首 页</a>
                <a href="http://www.tipask.com/download.html">下 载</a>                            
                <a href="http://www.tipask.com/case.php">案 例</a>
                <a href="http://www.tipask.com/buy.html">购 买</a>
                <a href="http://help.tipask.com">帮 助</a>
                <a href="http://bbs.tipask.com/">论 坛</a>
                <div class="clearer"><span></span></div>
            </div>	
            <!-- navigation ends-->	


            <div id="anli_content">
                <p />
                <div class="h2 r"><a href="http://bbs.tipask.com/viewthread.php?tid=4951"><span style="color: red;">我要申请成为案例站点</span></a></div>
                <p />
                <div class="clear"></div>
<?php
@$page = max(1, intval($_GET['page']));
$pagesize = 10;
$startindex = ($page - 1) * $pagesize; //每页面显示$pagesize条
$rownum = $db->fetch_total('case', '1=1');
$departstr = page($rownum, $pagesize, $page, "case.php?page=");

$sitelist = array();
$query = $db->query("SELECT * FROM `" . DB_TABLEPRE . "case` ORDER BY `displayorder` DESC LIMIT $startindex,$pagesize");
while ($site = $db->fetch_array($query)) {
    $site['addtime'] = date("Y-m-d H:i:s", $site['time']);
    $sitelist[] = $site;
}
?>

                <?php foreach ($sitelist as $site) { ?>
                    <dl class="jdal" >
                        <dd class="img"><img src="<?= $site['imgsrc'] ?>" height="60px" width="180" ></dd>
                        <dt class="h2"><span class="h3 r gray">加入时间：<?= $site['addtime'] ?></span><a href="<?= $site['href'] ?>" target="_blank"><?= $site['sitename'] ?></a></dt>
                        <dd><b>评价：</b><?= $site['mark'] ?>   分</dd>
                        <dd><b>网站简介：</b><?= $site['sitedesc'] ?></dd>
                    </dl>
<?php } ?>



                <div id="fenye" class="mar-tb8">
                <?php echo $departstr; ?>
                </div>	




            </div>

            <!-- footer starts -->			
            <div id="footer-wrap"><div id="footer">

                    <p>
                        &copy; 2009-2010 <a href="http://www.tipask.com/" title="Tipask">Tipask!</a>
                        <a href="http://bbs.tipask.com/">在线反馈</a> |
                        <a href="mailto:tipask@qq.com">联系我们</a>|
                        &nbsp;<a href="http://www.miibeian.gov.cn">京ICP备07008558号</a>
                    </p>

                </div></div>
            <!-- footer ends-->	

            <!-- wrap ends here -->
        </div>

    </body>
</html>
